//
//  XMIndexHeaderView.h
//  xiaorizi
//
//  Created by new-1020 on 2017/4/18.
//  Copyright © 2017年 begmoon. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "XMIndexHeaerViewConfig.h"
@class XMIndexHeaderView;


@protocol XMIndexHeaderViewDelegate <NSObject>

@optional
-(void)XMIndexHeaderViewDidselectedWithIndex:(NSInteger)index;
-(void)XMIndexHeaderViewDidselectedWithIndex:(NSInteger)index indexView:(XMIndexHeaderView *)indexheaderView;
-(BOOL)XMIndexHeaderViewShouldScrollToIndex:(NSInteger)index indexView:(XMIndexHeaderView *)indexheaderView;
-(void)customCell:(UICollectionViewCell *)cell cellForItemAtIndexPath:(NSIndexPath *)indexPath selectIndex:(NSInteger)selectIndex title:(NSString *)title;
-(CGSize)customCellSizeForItemAtIndexPath:(NSIndexPath *)indexPath;

-(UIView *)customLineView;
/// 自定义cell方法
//-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath;
@end

@interface XMIndexCollectionView : UICollectionView

@property(nonatomic,strong)void(^resizeBlock)(void);

@end

@interface XMIndexHeaderView : UIView

@property (nonatomic,assign) BOOL AnimationIsOpen;
@property (nonatomic,assign) BOOL hideLine;
@property (nonatomic,  weak) id <XMIndexHeaderViewDelegate> delegateXM;

@property (nonatomic,strong) UIColor *lineColor;
@property (nonatomic,assign) CGFloat lineWidth;
@property (nonatomic,strong) NSArray * changeTitleArray;
@property (nonatomic,strong) NSArray * changeTitleArrayNotRefresh;

@property (nonatomic,strong) UIColor * backGroundColor;
@property (nonatomic,assign) CGFloat  lineViewYset;   // 线条竖直上的偏移量
@property (nonatomic,strong) NSArray * titleArray;
@property (nonatomic,strong) XMIndexCollectionView * collectionView;
@property (nonatomic,assign) CGSize  itemSize;
@property(nonatomic,assign)  CGFloat  minimumLineSpacing;
@property (nonatomic,strong) UIColor *selectItemColor;
@property (nonatomic,strong) UIColor *unselectItemColor;
@property (nonatomic,assign) BOOL shouldAspect; // 是否需要自适应宽度
@property (nonatomic,assign) UIEdgeInsets   inset;
@property (nonatomic,assign) NSInteger currentINdex;
@property(nonatomic,strong) XMIndexHeaerViewConfig * config;

@property(nonatomic,assign)CGFloat  lineViewAlpha;


/**
 * 红点添加
 */
// 记录对应行的红点是否展示的字典
@property(nonatomic,strong)NSMutableDictionary *  readCountDic;
// 给某一行添加红点
-(void)setReadCount:(NSInteger)num withRow:(NSInteger)row;

-(instancetype)initWithFrame:(CGRect)frame WithTitleArray:(NSArray *)titleArray animation:(BOOL)animation;

-(instancetype)initWithFrame:(CGRect)frame WithTitleArray:(NSArray *)titleArray animation:(BOOL)animation delegate:(id<XMIndexHeaderViewDelegate>)delegate;


-(void)LineViewScrolleToIndex:(NSInteger)index;
-(void)LineViewScrolleToIndex:(NSInteger)index animation:(BOOL)animation;

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath;

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;

// 手动触发点击事件
-(void)didselectRow:(NSInteger)row;


-(void)registerNib;

-(void)fixLineView;
@end
